var myOrder = new Vue({
    el:'#myOrder',
    data:{
        repay:'',
        overRoomNum:'',
        finishMyOrder:[],
        unfinishMyOrder:[],
    },
    mounted:function () {
        $.ajax({
            url:"select_my_order",
            type:"POST",
            cache:false,
            dataType:'json',
            data:{

            },
            success:function (data) {
                var finishMyOrderDto = data.finishMyOrderDto;
                var unfinishMyOrderDto = data.unfinisMyOrderDto;
                myOrder.finishMyOrder = [];
                myOrder.unfinishMyOrder = [];
                for(var i=0;i<unfinishMyOrderDto.length;i++){
                    myOrder.unfinishMyOrder.push({
                        name:unfinishMyOrderDto[i].name,
                        roomNum:unfinishMyOrderDto[i].roomNum,
                        beginTime:unfinishMyOrderDto[i].beginTime,
                        stayDay:unfinishMyOrderDto[i].stayDay,
                        retal:unfinishMyOrderDto[i].retal,
                        pay:unfinishMyOrderDto[i].pay
                    });
                }
                for(var i=0;i<finishMyOrderDto.length;i++){
                    myOrder.finishMyOrder.push({
                        name:finishMyOrderDto[i].name,
                        roomNum:finishMyOrderDto[i].roomNum,
                        beginTime:finishMyOrderDto[i].beginTime,
                        stayDay:finishMyOrderDto[i].stayDay,
                        retal:finishMyOrderDto[i].retal,
                        pay:finishMyOrderDto[i].pay
                    });
                }
            }
        })

    },
    methods:{
        unsubscribe:function () {
            $.ajax({
                url:'settleAccounts',
                type:'POST',
                cache:false,
                dataType: 'json',
                data:{
                    'overRoomNum':this.overRoomNum
                },
                success:function(data){
                    if(data.status == "error"){
                        alert(data.info);
                        return;
                    }
                    myOrder.repay = data.info;
                    for(var i = 0;i<myOrder.unfinishMyOrder.length;i++){
                        if(myOrder.unfinishMyOrder[i].roomNum == this.overRoomNum){
                            myOrder.finishMyOrder.push(myOrder.unfinishMyOrder[i]);
                            for(var j = i;j<myOrder.unfinishMyOrder.length-1;j++){
                                myOrder.unfinishMyOrder[j] = myOrder.unfinishMyOrder[j+1];
                            }
                            myOrder.unfinishMyOrder.pop();
                            break;
                        }
                    }
                },
                error:function(){
                    alert("请刷新网络")
                }
            })
        }

    }

})























































